
import {createRouter,createWebHashHistory,createWebHistory,createMemoryHistory} from "vue-router"

let routes = [
    {
        path:"/",
        name:"/",//具名路由
        meta: { 
            name:'导航首页',
         },
        component:()=>import('../pages/home/index.vue'),
        children:[
            {
                path:"discover",
                name:'discover',
                meta:{
                    name:'发现首页'
                },
                component:()=>import('../pages/discover/index.vue'),
                redirect: "/discover/playlist",
                children:[
                    {
                        path:"playlist",
                        name:"plsylist",
                        meta:{
                            name:"歌单"
                        },
                        component:()=>import('../pages/discover/playlist/index.vue')
                    } 
                ]
                
            },
            {
                props:true,//路由解耦合
                path:"friend/:id",
                name:'friend',
                meta:{
                    name:"朋友"
                },
                component:()=>import('../pages/friend/index.vue')
            },
            {
                path:"mine",
                name:'mine',
                meta:{
                    name:"个人中心"
                },
                // 路由独享钩子,当前路由的前置守卫
                // 用法和router.beforeEach一模一样
                beforeEnter(to,from){
                    console.log('beforeEnter--to',to);
                    console.log('beforeEnter--from',from);
                },
                component:()=>import('../pages/mine/index.vue')
            },
        ]
    },
    {
        path:"/login",
        name:'login',
            meta:{
                name:"登入"
            },
        component:()=>import('../pages/login/index.vue')
    }
]

const router = createRouter({
    history:createWebHashHistory('/base'),//路由模式
    routes
})

export default router